package com.lohit.dbtest;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;

import org.xml.sax.DTDHandler;

import com.lohit.dbtest.service.ScheduleClient;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.app.TimePickerDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
import android.widget.AdapterView.OnItemSelectedListener;

public class RescheduleActivity extends Activity {

	final String s1 = "09:30 AM";
	final String s2 = "10:00 AM";
	final String s3 = "10:30 AM";
	final String s4 = "11:00 AM";
	final String s5 = "11:30 AM";
	final String s6 = "12:00 PM";
	final String s7 = "12:30 PM";

	final String s8 = "01:00 PM";

	final String s9 = "01:30 PM";

	final String s10 = "03:00 PM";

	final String s11 = "03:30 PM";

	final String s12 = "04:00 PM";

	final String s13 = "04:30 PM";

	final String s14 = "05:00 PM";

	final String s15 = "05:30 PM";

	final String s16 = "06:00 PM";

	final String s17 = "06:30 PM";

	final String s18 = "07:00 PM";

	final String s19 = "07:30 PM";
	final String s20 = "08:00 PM";

	String selectedTime;

	String d1;

	final Calendar c = Calendar.getInstance();
	Date dateObj;
	Context context = RescheduleActivity.this;

	Spinner timeSpinner;

	public static final String PREFS_APPOINTMENTS = "AppointmentDetails";

	DbController controller = new DbController(this);

	private ScheduleClient scheduleClient;

	SendSMS mSender = new SendSMS();

	Button cancelBtn, selectDateBtn, rescheduleAppBtn;

	TextView patientName, illness, location, date, time;

	String pName, alocation, aDate, aTime, aid, newDate, newTime, displayTime,
			phoneNumber, timeDB;

	Date todayDate = new Date();

	Date parsedTodayDate;
	String oldTime;
	String cause;
	java.util.Date temp;
	static final int DATE_DIALOG_ID = 1;
	static final int TIME_DIALOG_ID = 0;

	int mYear, mMonth, mDay;
	int hour, minute;

	@SuppressLint("SimpleDateFormat")
	@Override
	protected void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);

		setContentView(R.layout.activity_reschedule);

		init();

		Bundle extras = getIntent().getExtras();

		aDate = extras.getSerializable("date").toString();

		aTime = extras.getSerializable("time").toString();

		SimpleDateFormat calDateFormat = new SimpleDateFormat(
				"dd/MM/yyyy HH:mm:ss");
		SimpleDateFormat oldTimeFormat = new SimpleDateFormat("hh:mm aa");
		try {

			Date oldDate = calDateFormat.parse(aDate + " " + aTime);
			oldTime = oldTimeFormat.format(oldDate);

		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		Toast.makeText(context, aTime, Toast.LENGTH_SHORT).show();

		c.setTime(todayDate);

		// Adding 1 date so that the doctor reschedules the appointment for next
		// day onwards

		c.add(Calendar.DATE, 1);

		mYear = c.get(Calendar.YEAR);

		mMonth = c.get(Calendar.MONTH);

		mDay = c.get(Calendar.DAY_OF_MONTH);

		pName = extras.getSerializable("patientName").toString();

		cause = extras.getSerializable("sickness").toString();

		scheduleClient = new ScheduleClient(this);

		scheduleClient.doBindService();

		alocation = extras.getSerializable("location").toString();

		aid = extras.getSerializable("aid").toString();

		phoneNumber = extras.getSerializable("number").toString();

		Log.d("num", phoneNumber);

		patientName.setText(pName);

		illness.setText(cause);

		location.setText(alocation);

		timeSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

			@Override
			public void onItemSelected(AdapterView<?> arg0, View arg1,
					int arg2, long arg3) {

				selectedTime = timeSpinner.getSelectedItem().toString();

			}

			@Override
			public void onNothingSelected(AdapterView<?> arg0) {
				// TODO Auto-generated method stub

			}

		});

	}

	@Override
	protected Dialog onCreateDialog(int id) {

		switch (id) {

		case DATE_DIALOG_ID:
			return new DatePickerDialog(this, mDateSetListener, mYear, mMonth,
					mDay);

		}

		return null;

	}

	public void init() {

		patientName = (TextView) findViewById(R.id.patientNameRescheduleTextView);

		illness = (TextView) findViewById(R.id.patientIllnessRescheduleTextView);

		location = (TextView) findViewById(R.id.appointmentLocationRescheduleTextView);

		date = (TextView) findViewById(R.id.appDateRescheduleTextView);

		timeSpinner = (Spinner) findViewById(R.id.timeSpinnerRes);

		cancelBtn = (Button) findViewById(R.id.cancelRescheduleButton);

		selectDateBtn = (Button) findViewById(R.id.dateSelectionButton);

		rescheduleAppBtn = (Button) findViewById(R.id.rescheduleRescheduleAppointmentButton);

	}

	private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() {

		@Override
		public void onDateSet(DatePicker view, int year, int monthOfYear,
				int dayOfMonth) {

			mYear = year;

			mMonth = monthOfYear + 1;

			mDay = dayOfMonth;

			date.setText(pad(mDay) + "/" + pad(mMonth) + "/" + mYear);

			d1 = date.getText().toString();

			ArrayList<String> slots = controller.getSlots(d1);

			if (slots.isEmpty()) {

				Toast.makeText(
						context,
						"No Available timmings on " + d1
								+ ". Please choose another date",
						Toast.LENGTH_LONG).show();

			}

			ArrayAdapter<String> adap = new ArrayAdapter<String>(context,
					android.R.layout.simple_list_item_1, slots);

			adap.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

			timeSpinner.setAdapter(adap);

			newDate = pad(mDay) + "/" + pad(mMonth) + "/" + mYear;

			Log.d("new date", newDate);

		}
	};

	public static String pad(int c) {

		String cc;

		if (c < 10) {

			cc = "0" + c;

			return cc;

		} else {

			return String.valueOf(c);
		}

	}

	public void message() {

		Toast.makeText(this, "Appointment successfuly recheduled ",
				Toast.LENGTH_LONG).show();

	}

	public void negmessage() {

		Toast.makeText(this, "Error processing your request. Please try again",
				Toast.LENGTH_LONG).show();
	}

	@Override
	protected void onResume() {
		super.onResume();

		selectDateBtn.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {

				showDialog(DATE_DIALOG_ID);

			}
		});

		cancelBtn.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {

				Intent i = new Intent(RescheduleActivity.this, Main.class);
				startActivity(i);

			}
		});

		rescheduleAppBtn.setOnClickListener(new OnClickListener() {

			@SuppressLint("SimpleDateFormat")
			@Override
			public void onClick(View v) {

				SimpleDateFormat sdf = new SimpleDateFormat(
						"dd/MM/yyyy hh:mm aa");

				Date checkDate = c.getTime();

				String d = date.getText().toString();

				try {

					dateObj = sdf.parse(d + " " + selectedTime);

					SimpleDateFormat sdf2 = new SimpleDateFormat("HH:mm:ss");

					timeDB = sdf2.format(dateObj);

				} catch (ParseException e1) {

					e1.printStackTrace();

				}

				if (dateObj.after(checkDate)) {

					SharedPreferences app_settings = getSharedPreferences(
							PREFS_APPOINTMENTS, 0);

					if (selectedTime.equals(s1)) {
						Toast.makeText(context, "slot1 if block",
								Toast.LENGTH_LONG).show();

						int im = controller.setSlot(d, "slot1");

						if (im == 1) {

							Toast.makeText(context,
									"Appointment Created at" + selectedTime,
									Toast.LENGTH_LONG).show();
						} else {

							Toast.makeText(context, "Error", Toast.LENGTH_LONG)
									.show();
						}

					} else if (selectedTime.equals(s2)) {
						Toast.makeText(context, "slot2 if block",
								Toast.LENGTH_LONG).show();

						int im = controller.setSlot(d, "slot2");

						if (im == 1) {

							Toast.makeText(context,
									"Appointment Created at" + selectedTime,
									Toast.LENGTH_LONG).show();
						} else {
							Toast.makeText(context, "Error", Toast.LENGTH_LONG)
									.show();
						}

					} else if (selectedTime.equals(s3)) {
						Toast.makeText(context, "slot3 if block",
								Toast.LENGTH_LONG).show();

						int im = controller.setSlot(d, "slot3");
						if (im == 1) {

							Toast.makeText(context,
									"Appointment Created at" + selectedTime,
									Toast.LENGTH_LONG).show();
						} else {
							Toast.makeText(context, "Error", Toast.LENGTH_LONG)
									.show();
						}

					} else if (selectedTime.equals(s4)) {

						Toast.makeText(context, "slot4 if block",
								Toast.LENGTH_LONG).show();

						int im = controller.setSlot(d, "slot4");

						if (im == 1) {

							Toast.makeText(context,
									"Appointment Created at" + selectedTime,
									Toast.LENGTH_LONG).show();
						} else {
							Toast.makeText(context, "Error", Toast.LENGTH_LONG)
									.show();
						}

					} else if (selectedTime.equals(s5)) {
						Toast.makeText(context, "slot5 if block",
								Toast.LENGTH_LONG).show();

						int im = controller.setSlot(d, "slot5");

						if (im == 1) {

							Toast.makeText(context,
									"Appointment Created at" + selectedTime,
									Toast.LENGTH_LONG).show();
						}
					}

					else if (selectedTime.equals(s6)) {

						Toast.makeText(context, "slot6 if block",
								Toast.LENGTH_LONG).show();

						int im = controller.setSlot(d, "slot6");

						if (im == 1) {

							Toast.makeText(context,
									"Appointment Created at" + selectedTime,
									Toast.LENGTH_LONG).show();
						}
					} else if (selectedTime.equals(s7)) {
						Toast.makeText(context, "slot7 if block",
								Toast.LENGTH_LONG).show();

						int im = controller.setSlot(d, "slot7");

						if (im == 1) {

							Toast.makeText(context,
									"Appointment Created at" + selectedTime,
									Toast.LENGTH_LONG).show();
						}
					} else if (selectedTime.equals(s8)) {
						Toast.makeText(context, "slot8 if block",
								Toast.LENGTH_LONG).show();

						int im = controller.setSlot(d, "slot8");

						if (im == 1) {

							Toast.makeText(context,
									"Appointment Created at" + selectedTime,
									Toast.LENGTH_LONG).show();

						}
					}

					else if (selectedTime.equals(s9)) {
						Toast.makeText(context, "slot9 if block",
								Toast.LENGTH_LONG).show();

						int im = controller.setSlot(d, "slot9");

						if (im == 1) {

							Toast.makeText(context,
									"Appointment Created at" + selectedTime,
									Toast.LENGTH_LONG).show();
						}
					}

					else if (selectedTime.equals(s10)) {
						Toast.makeText(context, "slot10 if block",
								Toast.LENGTH_LONG).show();

						int im = controller.setSlot(d, "slot10");

						if (im == 1) {

							Toast.makeText(context,
									"Appointment Created at" + selectedTime,
									Toast.LENGTH_LONG).show();
						}
					}

					else if (selectedTime.equals(s11)) {
						Toast.makeText(context, "slot15 if block",
								Toast.LENGTH_LONG).show();

						int im = controller.setSlot(d, "slot11");

						if (im == 1) {

							Toast.makeText(context,
									"Appointment Created at" + selectedTime,
									Toast.LENGTH_LONG).show();
						}
					}

					else if (selectedTime.equals(s12)) {
						Toast.makeText(context, "slot12 if block",
								Toast.LENGTH_LONG).show();

						int im = controller.setSlot(d, "slot12");

						if (im == 1) {

							Toast.makeText(context,
									"Appointment Created at" + selectedTime,
									Toast.LENGTH_LONG).show();
						}
					} else if (selectedTime.equals(s13)) {
						Toast.makeText(context, "slot13 if block",
								Toast.LENGTH_LONG).show();

						int im = controller.setSlot(d, "slot13");

						if (im == 1) {

							Toast.makeText(context,
									"Appointment Created at" + selectedTime,
									Toast.LENGTH_LONG).show();
						}
					}

					else if (selectedTime.equals(s14)) {
						Toast.makeText(context, "slot14 if block",
								Toast.LENGTH_LONG).show();

						int im = controller.setSlot(d, "slot14");

						if (im == 1) {

							Toast.makeText(context,
									"Appointment Created at" + selectedTime,
									Toast.LENGTH_LONG).show();
						}
					} else if (selectedTime.equals(s15)) {
						Toast.makeText(context, "slot15 if block",
								Toast.LENGTH_LONG).show();

						int im = controller.setSlot(d, "slot15");

						if (im == 1) {

							Toast.makeText(context,
									"Appointment Created at" + selectedTime,
									Toast.LENGTH_LONG).show();
						}
					}

					else if (selectedTime.equals(s16)) {
						Toast.makeText(context, "slot16 if block",
								Toast.LENGTH_LONG).show();

						int im = controller.setSlot(d, "slot16");

						if (im == 1) {

							Toast.makeText(context,
									"Appointment Created at" + selectedTime,
									Toast.LENGTH_LONG).show();
						}
					} else if (selectedTime.equals(s17)) {
						Toast.makeText(context, "slot17 if block",
								Toast.LENGTH_LONG).show();

						int im = controller.setSlot(d, "slot17");

						if (im == 1) {

							Toast.makeText(context,
									"Appointment Created at" + selectedTime,
									Toast.LENGTH_LONG).show();
						}
					} else if (selectedTime.equals(s18)) {
						Toast.makeText(context, "slot18 if block",
								Toast.LENGTH_LONG).show();

						int im = controller.setSlot(d, "slot18");

						if (im == 1) {

							Toast.makeText(context,
									"Appointment Created at" + selectedTime,
									Toast.LENGTH_LONG).show();
						}
					}

					else if (selectedTime.equals(s19)) {
						Toast.makeText(context, "slot19 if block",
								Toast.LENGTH_LONG).show();

						int im = controller.setSlot(d, "slot19");

						if (im == 1) {

							Toast.makeText(context,
									"Appointment Created at" + selectedTime,
									Toast.LENGTH_LONG).show();
						}
					} else if (selectedTime.equals(s20)) {
						Toast.makeText(context, "slot20 if block",
								Toast.LENGTH_LONG).show();

						int im = controller.setSlot(d, "slot20");

						if (im == 1) {

							Toast.makeText(context,
									"Appointment Created at" + selectedTime,
									Toast.LENGTH_LONG).show();
						}
					}

					else {

						Toast.makeText(context, "Error", Toast.LENGTH_LONG)
								.show();

					}

					int i = controller.reschedule(aid, d, timeDB);

					if (i == 1) {

						
						uncheckSlot();
						
						SharedPreferences.Editor editor = app_settings.edit();

						editor.putString("patientName", pName);

						editor.commit();

						Calendar calendar = Calendar.getInstance();

						calendar.setTime(dateObj);

						int month = calendar.get(Calendar.MONTH);

						int year = calendar.get(Calendar.YEAR);

						int day = calendar.get(Calendar.DAY_OF_MONTH);

						int hours = calendar.get(Calendar.HOUR_OF_DAY);

						int minutes = calendar.get(Calendar.MINUTE);

						int seconds = calendar.get(Calendar.SECOND);

						Calendar c2 = Calendar.getInstance();
						int priorHour = hours - 1;

						c2.set(year, month, day);

						c2.set(Calendar.HOUR_OF_DAY, priorHour);
						c2.set(Calendar.MINUTE, minutes);
						c2.set(Calendar.SECOND, seconds);

						Log.d("calender", c2.toString());

						scheduleClient.setAlarmForNotification(c2);

						String message = "Dear Valued customer due to some circumstances your appoint has been preponed/postponed on '"
								+ d + "' at '" + selectedTime + "' ";

						boolean success = mSender.sendSMSMessage(phoneNumber,
								message);

						message();

						smsMessage(success);
						Intent o = new Intent(RescheduleActivity.this,
								Main.class);
						startActivity(o);

					} else {

						negmessage();

						Intent o = new Intent(RescheduleActivity.this,
								Main.class);

						startActivity(o);

					}

				} else {

					Toast.makeText(context,
							"Invalid date. Please select another date",
							Toast.LENGTH_SHORT).show();

				}

			}

		});

	}

	public void invalidDate() {
		Toast.makeText(this, "Choose different Date or time ",
				Toast.LENGTH_LONG).show();

	}

	private void smsMessage(boolean success) {

		Toast.makeText(
				this,
				"Message sent " + (success ? "successfully" : "unsuccessfully"),
				Toast.LENGTH_SHORT).show();

	}

	private void uncheckSlot() {

		if (oldTime.equals(s1)) {
			Toast.makeText(context, "slot1 if block", Toast.LENGTH_LONG).show();

			int im = controller.uncheckSlot(aDate, "slot1");

			if (im == 1) {

				Toast.makeText(context,
						"Slot unchecked at" + oldTime,
						Toast.LENGTH_LONG).show();
			} else {

				Toast.makeText(context, "Error", Toast.LENGTH_LONG).show();
			}

		} else if (oldTime.equals(s2)) {
			Toast.makeText(context, "slot2 if block", Toast.LENGTH_LONG).show();

			int im = controller.uncheckSlot(aDate, "slot2");

			if (im == 1) {

				Toast.makeText(context,
						"Slot unchecked at" + oldTime,
						Toast.LENGTH_LONG).show();
			} else {
				Toast.makeText(context, "Error", Toast.LENGTH_LONG).show();
			}

		} else if (oldTime.equals(s3)) {
			Toast.makeText(context, "slot3 if block", Toast.LENGTH_LONG).show();

			int im = controller.uncheckSlot(aDate, "slot3");
			if (im == 1) {

				Toast.makeText(context,
						"Slot unchecked at" + oldTime,
						Toast.LENGTH_LONG).show();
			} else {
				Toast.makeText(context, "Error", Toast.LENGTH_LONG).show();
			}

		} else if (oldTime.equals(s4)) {

			Toast.makeText(context, "slot4 if block", Toast.LENGTH_LONG).show();

			int im = controller.uncheckSlot(aDate, "slot4");

			if (im == 1) {

				Toast.makeText(context,
						"Slot unchecked at" + oldTime,
						Toast.LENGTH_LONG).show();
			} else {
				Toast.makeText(context, "Error", Toast.LENGTH_LONG).show();
			}

		} else if (oldTime.equals(s5)) {
			Toast.makeText(context, "slot5 if block", Toast.LENGTH_LONG).show();

			int im = controller.uncheckSlot(aDate, "slot5");

			if (im == 1) {

				Toast.makeText(context,
						"Slot unchecked at" + oldTime,
						Toast.LENGTH_LONG).show();
			}
		}

		else if (oldTime.equals(s6)) {

			Toast.makeText(context, "slot6 if block", Toast.LENGTH_LONG).show();

			int im = controller.uncheckSlot(aDate, "slot6");

			if (im == 1) {

				Toast.makeText(context,
						"Slot unchecked at" + oldTime,
						Toast.LENGTH_LONG).show();
			}
		} else if (oldTime.equals(s7)) {
			Toast.makeText(context, "slot7 if block", Toast.LENGTH_LONG).show();

			int im = controller.uncheckSlot(aDate, "slot7");

			if (im == 1) {

				Toast.makeText(context,
						"Slot unchecked at" + oldTime,
						Toast.LENGTH_LONG).show();
			}
		} else if (oldTime.equals(s8)) {
			Toast.makeText(context, "slot8 if block", Toast.LENGTH_LONG).show();

			int im = controller.uncheckSlot(aDate, "slot8");

			if (im == 1) {

				Toast.makeText(context,
						"Slot unchecked at" + oldTime,
						Toast.LENGTH_LONG).show();

			}
		}

		else if (oldTime.equals(s9)) {
			Toast.makeText(context, "slot9 if block", Toast.LENGTH_LONG).show();

			int im = controller.uncheckSlot(aDate, "slot9");

			if (im == 1) {

				Toast.makeText(context,
						"Slot unchecked at" + oldTime,
						Toast.LENGTH_LONG).show();
			}
		}

		else if (oldTime.equals(s10)) {
			Toast.makeText(context, "slot10 if block", Toast.LENGTH_LONG)
					.show();

			int im = controller.uncheckSlot(aDate, "slot10");

			if (im == 1) {

				Toast.makeText(context,
						"Slot unchecked at" + oldTime,
						Toast.LENGTH_LONG).show();
			}
		}

		else if (oldTime.equals(s11)) {
			Toast.makeText(context, "slot15 if block", Toast.LENGTH_LONG)
					.show();

			int im = controller.uncheckSlot(aDate, "slot11");

			if (im == 1) {

				Toast.makeText(context,
						"Slot unchecked at" + oldTime,
						Toast.LENGTH_LONG).show();
			}
		}

		else if (oldTime.equals(s12)) {
			Toast.makeText(context, "slot12 if block", Toast.LENGTH_LONG)
					.show();

			int im = controller.uncheckSlot(aDate, "slot12");

			if (im == 1) {

				Toast.makeText(context,
						"Slot unchecked at" + oldTime,
						Toast.LENGTH_LONG).show();
			}
		} else if (oldTime.equals(s13)) {
			Toast.makeText(context, "slot13 if block", Toast.LENGTH_LONG)
					.show();

			int im = controller.uncheckSlot(aDate, "slot13");

			if (im == 1) {

				Toast.makeText(context,
						"Slot unchecked at" + oldTime,
						Toast.LENGTH_LONG).show();
			}
		}

		else if (oldTime.equals(s14)) {
			Toast.makeText(context, "slot14 if block", Toast.LENGTH_LONG)
					.show();

			int im = controller.uncheckSlot(aDate, "slot14");

			if (im == 1) {

				Toast.makeText(context,
						"Slot unchecked at" + oldTime,
						Toast.LENGTH_LONG).show();
			}
		} else if (oldTime.equals(s15)) {
			Toast.makeText(context, "slot15 if block", Toast.LENGTH_LONG)
					.show();

			int im = controller.uncheckSlot(aDate, "slot15");

			if (im == 1) {

				Toast.makeText(context,
						"Slot unchecked at" + oldTime,
						Toast.LENGTH_LONG).show();
			}
		}

		else if (oldTime.equals(s16)) {
			Toast.makeText(context, "slot16 if block", Toast.LENGTH_LONG)
					.show();

			int im = controller.uncheckSlot(aDate, "slot16");

			if (im == 1) {

				Toast.makeText(context,
						"Slot unchecked at" + oldTime,
						Toast.LENGTH_LONG).show();
			}
		} else if (oldTime.equals(s17)) {
			Toast.makeText(context, "slot17 if block", Toast.LENGTH_LONG)
					.show();

			int im = controller.uncheckSlot(aDate, "slot17");

			if (im == 1) {

				Toast.makeText(context,
						"Slot unchecked at" + oldTime,
						Toast.LENGTH_LONG).show();
			}
		} else if (oldTime.equals(s18)) {
			Toast.makeText(context, "slot18 if block", Toast.LENGTH_LONG)
					.show();

			int im = controller.uncheckSlot(aDate, "slot18");

			if (im == 1) {

				Toast.makeText(context,
						"Slot unchecked at" + oldTime,
						Toast.LENGTH_LONG).show();
			}
		}

		else if (oldTime.equals(s19)) {
			Toast.makeText(context, "slot19 if block", Toast.LENGTH_LONG)
					.show();

			int im = controller.uncheckSlot(aDate, "slot19");

			if (im == 1) {

				Toast.makeText(context,
						"Slot unchecked at" + oldTime,
						Toast.LENGTH_LONG).show();
			}
		} else if (oldTime.equals(s20)) {
			Toast.makeText(context, "slot20 if block", Toast.LENGTH_LONG)
					.show();

			int im = controller.uncheckSlot(aDate, "slot20");

			if (im == 1) {

				Toast.makeText(context,
						"Slot unchecked at" + oldTime,
						Toast.LENGTH_LONG).show();
			}

		}

	}

}
